package com.smartao.base.menu;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.smartao.base.init.InitializeServiceOrder;
import com.smartao.core.init.AbstractDataInitializeService;

@Service
public class MenuInitializeService extends AbstractDataInitializeService {

	protected final int order = InitializeServiceOrder.INIT_ORDER_MENU;

	@Autowired
	private MenuService menuService;

	@Override
	public int getOrder() {
		return order;
	}

	@Override
	public void initData() throws Exception {
		List<Menu> menus = menuService.findByMenutype(MenuType.admin);
		if(menus!=null && menus.size()!=0){
			return;
		}
		Menu sysInfoMenu = new Menu("系统运行参数", MenuType.admin);
		sysInfoMenu.setUrl("admin/main!sysinfo.action");
		menuService.save(sysInfoMenu);
		
		Menu menuSetting = new Menu("菜单设置", MenuType.admin);
		menuService.save(menuSetting);

		Menu sysMenuSetting = new Menu("系统菜单", MenuType.admin);
		sysMenuSetting.setUrl("base/menu/menu.action?menuType=admin");
		sysMenuSetting.setParent(menuSetting);
		menuService.save(sysMenuSetting);
		
		Menu userMenuSetting = new Menu("用户菜单", MenuType.admin);
		userMenuSetting.setUrl("base/menu/menu.action?menuType=user");
		userMenuSetting.setParent(menuSetting);
		menuService.save(userMenuSetting);

		Menu navMenuSetting = new Menu("快捷菜单", MenuType.admin);
		navMenuSetting.setUrl("base/menu/menu.action?menuType=shortcut");
		navMenuSetting.setParent(menuSetting);
		menuService.save(navMenuSetting);

		Menu m2 = new Menu("系统监控", MenuType.admin);
		menuService.save(m2);
		
		Menu m3 = new Menu("操作日志", MenuType.admin);
		m3.setParent(m2);
		menuService.save(m3);
		
		Menu m4 = new Menu("在线人员", MenuType.admin);
		m4.setUrl("admin/main!onlineUsers.action");
		m4.setParent(m2);
		menuService.save(m4);
		
		Menu m5 = new Menu("人力资源", MenuType.admin);
		menuService.save(m5);
		
		Menu m6 = new Menu("组织单元", MenuType.admin);
		m6.setUrl("base/department/department.action");
		m6.setParent(m5);
		menuService.save(m6);
		
		Menu m7 = new Menu("人员管理", MenuType.admin);
		m7.setUrl("base/employee/employee.action");
		m7.setParent(m5);
		menuService.save(m7);
		
		Menu m8 = new Menu("岗位管理", MenuType.admin);
		m8.setUrl("base/position/position.action");
		m8.setParent(m5);
		menuService.save(m8);
		
		Menu m9 = new Menu("角色和权限管理", MenuType.admin);
		menuService.save(m9);
		
		Menu m10 = new Menu("角色管理", MenuType.admin);
		m10.setUrl("base/role/role.action");
		m10.setParent(m9);
		menuService.save(m10);
		
		Menu m11 = new Menu("模块管理", MenuType.admin);
		menuService.save(m11);
		
		Menu m12 = new Menu("模块管理", MenuType.admin);
		m12.setUrl("base/module/module.action");
		m12.setParent(m11);
		menuService.save(m12);
		
		Menu setting = new Menu("系统设置", MenuType.admin);
		menuService.save(setting);
		
		Menu setting1 = new Menu("登录与安全设置", MenuType.admin, setting);
		setting1.setUrl("base/config/security-config.action");
		menuService.save(setting1);
		
		Menu setting2 = new Menu("系统提醒设置", MenuType.admin, setting);
		setting2.setUrl("base/config/notification-config.action");
		menuService.save(setting2);
	}
}
